<#include "/common/head.ftl">

<html>
<head>
<title>Attendance - ${model.offering.name}</title>
<style type="text/css">
body {
	padding: 0;
}

.center {
	text-align: center;
}

.sanserif {
	font-family: Arial;
	font-size: 10px;
}

#wrapper {
	width: 28cm;
	text-align: left;
	margin: auto;
	padding: 0;
}

table.nameTable {
	empty-cells: show;
	border-collapse: collapse;
	border: 1px solid black;
	width: 100%;
	margin: 0;
	padding: 0;	
}

table.nameTable th {
	background: #F0FFF0;
	border: 1px solid black;
}

table.nameTable td {
	border: 1px solid black;
	min-width: 12px;
}

table.nameTable td.nowrap {
	white-space: nowrap;
}
</style>

<#macro formatOn status>
	<#if status == "A">
		;background-color: yellow;
	</#if>
</#macro>
	
</head>

<body>
<div id="wrapper">
<h2 class="center">ATTENDANCE LIST</h2>
<div style="height:3cm;font-size:10pt">
	<div style="float:left;width:8cm;height:2.3cm;margin-left:0.5cm;font-size:10pt">
		<table style="font-weight:bold;font-size:10pt;">
			<tr>
				<td style="text-align:right">Class :</td>
				<td>${model.offering.name}</td>
			</tr>
			<tr>
				<td style="text-align:right">Time :</td>
				<td>${(model.offering.shift.startTime?time)!}-${(model.offering.shift.endTime?time)!}</td>
			</tr>
			<tr>
				<td style="text-align:right">Teachers :</td>
				<td>
					<#list model.offering.instructors as teacher>
						${i18n.getMessage(teacher.title.key)} ${teacher.firstName}<#if teacher_index + 1 < model.offering.instructors.size()>, </#if>
					</#list>
				</td>
			</tr>
			<tr>
				<td style="text-align:right">Date :</td>
				<td>${model.offering.startDate?date} - ${model.offering.endDate?date}</td>
			</tr>
			<tr>
				<td style="text-align:right">Room :</td>
				<td>${(model.offering.room.code)!}</td>
			</tr>
		</table>
	</div>
	
	<div style="float:left;width:8cm;height:2.3cm;margin-left:8cm;margin-top:0.5cm">
		<div style="border:1px solid black;padding:0.1cm">
			If you have any suggestions, <br/>
			please note in the follow-up register
		</div>
		<br/>		
		<span style="font-weight:bold;margin-top:1cm">NO RECEIPT, NO ADMITTANCE</span>
	</div>
</div>

<table class="nameTable" border="0" cellspacing="0" cellpadding=0">
	<tr style="text-align:center;font-weight:bold;height:0.5cm;font-size:9pt">
		<th rowspan="3">No.</th>
		<th rowspan="3" colspan="2">Full Name</th>
		<th rowspan="3">Nickname</th>
		<th rowspan="3" style="width: 2cm;">Phone</th>
		<th rowspan="3">Receipt</th>
		<#list model.months as month>
			<th colspan="${model.getDays(month)}">${month}</th>
		</#list>
	</tr>
	<tr style="text-align:center;height:0.5cm;font-size:9pt">
		<#list model.weeks.keySet() as week>
			<th colspan="${model.weeks.get(week)}">Week<br/>${week_index + 1}</th>
		</#list>
	</tr>
	<tr style="text-align:center;height:0.5cm;font-size:9pt">
		<#list model.days as day>
			<th>${day?string('d')}</th>
		</#list>
	</tr>
	<#assign memberCount = (model.offering.members.size())!>
	<#list model.offeringMembers as member>
		<tr style="font-size: 9pt;height:0.6cm">
			<td style="width:0.7cm;height:0.5cm;text-align:center">${member_index + 1}</td>
			<td class="nowrap" style="border-right: none;">${(member.receipt.student.lastName)!'&nbsp'}</td>
			<td>${(member.receipt.student.firstName)!'&nbsp'}</td>
			<td>&nbsp</td>
			<td>${(View.trimPhoneNumber(member.receipt.student.phoneNumber))!'&nbsp'}</td>
			<td style="width:1cm;padding:0cm;text-align:center">${(member.receipt.number)!'&nbsp'}</td>
			<#list model.days as day>
				<#assign s = model.interrupted(day)>
				<#if s == 1>
					<#if member_index == 0>
						<td rowspan="${model.offeringMembers.size()}" style="font-weight:bold;text-align:center">C<br/>A<br/>N<br/>C<br/>E<br/>L</td>
					</#if>
				<#elseif s == 2>
					<#if member_index == 0>
						<td rowspan="${model.offeringMembers.size()}" style="font-weight:bold;text-align:center">H<br/>O<br/>L<br/>I<br/>D<br/>A<br/>Y</td>
					</#if>
				<#else>
					<td class="sanserif center" style="<@formatOn (i18n.getMessage(member.getAttendance(day).status.key))!'&nbsp;'/>">
						${(i18n.getMessage(member.getAttendance(day).status.key))!'&nbsp;'}
					</td>
				</#if>
			</#list>
		</tr>
	</#list>
</table>
<br/>
<div style="text-align:left"><b>* <u>Note:</u></b> Please put <b>"A"</b> for absent students, and check <b>"P"</b> for present ones</div>
</div>
</body>
</html>